﻿<script type="text/javascript">

    var TimingFlow = {};
    TimingFlow.DelUrl = "";
    TimingFlow.EditUrl = "";
    TimingFlow.DeleteFormatter = function (value, rec, index) {
        if (rec.StateID == 1)
            return "";
        return "<a  class='btn-del' href='" + TimingFlow.DelUrl + "?flowID=" + rec.UID + "' onclick='TimingFlow.Delete(this); return false;' >删除</a>";
    }

    TimingFlow.EditFormatter = function (value, rec, index) {
        return "<a  class='btn-edit' href='" + TimingFlow.EditUrl + "?flowID=" + rec.UID + "' onclick='TimingFlow.Edit(this); return false;' >修改</a>";
    }

    TimingFlow.Delete = function (e) {
        if (!confirm("确认要删除吗？"))
            return;
        $.post($(e).attr("href"), function (data) {
            if (data.IsOK) {
                $(".tabs-panels .panel:visible").find('#tbFlowList').datagrid('reload');
            }
            else
                alert(data.Description);
        });
    }

    TimingFlow.Edit = function (e) {
        $.createWin({ url: e.href, width: 600, height: 550, title: '修改定时服务流程' });
        return false;
    }

    $(document).ready(function () {
        TimingFlow.DelUrl = $(".tabs-panels .panel:visible").find("#delFlowUrl").val();
        TimingFlow.EditUrl = $(".tabs-panels .panel:visible").find("#editFlowUrl").val();
        $(".tabs-panels .panel:visible").find('#tbFlowList').datagrid({ pagination: true });
    });

</script>
@Html.Hidden("delFlowUrl", Url.Action("DeleteFlow", new { id = ViewBag.TimingServiceID }))
@Html.Hidden("editFlowUrl", Url.Action("EditFlow", new { id = ViewBag.TimingServiceID }))
<div class="tt-attach">
    <ul class="op">
        <li>
            @Html.ActionLink("新增流程", "InsertFlow", new { id = ViewBag.TimingServiceID }, new { onclick = "$.createWin({ url: this.href, width: 600, height: 550, title: '新增定时服务流程' }); return false;", @class = "btn btn-insertarticle" })
        </li>
    </ul>
</div>
<div style="padding: 5px 10px;">
    <table id="tbFlowList" style="height: auto" striped="true" nowrap="false" fitColumns="true" title="" iconcls="icon-edit"
    singleselect="true" idfield="UID" url="@Url.Action("FlowListData", new { id = ViewBag.TimingServiceID })">
        <thead>
            <tr>
                <th field="Flow" width="50" align="center">
                    步骤序号
                </th>
                <th field="FlowName" width="150">
                    流程名称
                </th>
                <th field="Assembly" width="150">
                    程序集
                </th>
                <th field="ClassName" width="250">
                    类名
                </th>
                <th title="成功执行步骤序号" field="OkFLow" width="50" align="center">
                    成功
                </th>
                <th title="失败执行步骤序号" field="ErrFlow" width="50" align="center">
                    失败
                </th>
                <th field="Remark" width="100" align="center">
                    备注
                </th>
                <th field="修改" width="50" formatter="TimingFlow.EditFormatter" align="center">
                    修改
                </th>
                <th field="删除" width="50" formatter="TimingFlow.DeleteFormatter" align="center">
                    删除
                </th>
            </tr>
        </thead>
    </table>
</div>
